package com.ctvit.sjk.knowledge.app.pojo.vo;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ctvit.sjk.knowledge.app.pojo.domain.TabApp;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.ObjectUtils;

import java.time.LocalDateTime;

import static com.ctvit.sjk.knowledge.core.constant.KnowledgeConstant.JSON_OBJECT_EMPTY;

/**
 * 应用查询VO
 *
 * @author heyingcheng
 * @date 2025/03/28
 */
@Getter
@Setter
@ToString
public class AppGetVO {

    private String id;
    private String name;
    private String desc;
    private String prologue;
    @JsonProperty("dialogue_number")
    private Integer dialogueNumber;
    @JsonProperty("dataset_setting")
    private JSONObject datasetSetting;
    @JsonProperty("model_setting")
    private JSONObject modelSetting;
    @JsonProperty("problem_optimization")
    private Boolean problemOptimization;
    @JsonProperty("model_id")
    private String modelId;
    @JsonProperty("user_id")
    private String userId;
    private String icon;
    private String type;
    @JsonProperty("work_flow")
    private String workFlow;
    @JsonProperty("model_params_setting")
    private JSONObject modelParamsSetting;
    @JsonProperty("stt_model_id")
    private String sttModelId;
    @JsonProperty("stt_model_enable")
    private Boolean sttModelEnable;
    @JsonProperty("stt_model_params_setting")
    private JSONObject sttModelParamSetting;
    @JsonProperty("tts_model_id")
    private String ttsModelId;
    @JsonProperty("tts_model_enable")
    private Boolean ttsModelEnable;
    @JsonProperty("tts_type")
    private String ttsType;
    @JsonProperty("problem_optimization_prompt")
    private String problemOptimizationPrompt;
    @JsonProperty("tts_model_params_setting")
    private JSONObject ttsModelParamsSetting;
    @JsonProperty("clean_time")
    private Integer cleanTime;
    @JsonProperty("file_upload_enable")
    private Boolean fileUploadEnable;
    @JsonProperty("file_upload_setting")
    private JSONObject fileUploadSetting;
    @JsonProperty("tts_autoplay")
    private Boolean ttsAutoplay;
    @JsonProperty("stt_autosend")
    private Boolean sttAutosend;
    @JsonProperty("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;
    @JsonProperty("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;

    public AppGetVO(TabApp entity) {
        this.id = entity.getAppId();
        this.name = entity.getAppName();
        this.desc = entity.getAppDesc();
        this.prologue = entity.getPrologue();
        this.dialogueNumber = entity.getDialogueNum();
        this.datasetSetting = JSON.parseObject(ObjectUtils.defaultIfNull(entity.getDatasetSetting(), JSON_OBJECT_EMPTY));
        this.modelSetting = JSON.parseObject(ObjectUtils.defaultIfNull(entity.getModelSetting(), JSON_OBJECT_EMPTY));
        this.problemOptimization = entity.getProblemOptimization();
        this.modelId = entity.getModelId();
        this.userId = entity.getCreateId();
        this.icon = entity.getAppIcon();
        this.type = entity.getAppType();
        this.workFlow = entity.getWorkflow();
        this.modelParamsSetting = JSON.parseObject(ObjectUtils.defaultIfNull(entity.getModelParamSetting(), JSON_OBJECT_EMPTY));
        this.sttModelId = entity.getSttModelId();
        this.sttModelEnable = entity.getSttModelEnable();
        this.ttsModelId = entity.getTtsModelId();
        this.ttsModelEnable = entity.getTtsModelEnable();
        this.ttsType = entity.getTtsType();
        this.problemOptimizationPrompt = entity.getProblemOptimizationPrompt();
        this.ttsModelParamsSetting = JSON.parseObject(ObjectUtils.defaultIfNull(entity.getTtsModelParamSetting(), JSON_OBJECT_EMPTY));
        this.cleanTime = entity.getCleanTime();
        this.fileUploadEnable = entity.getFileUploadEnable();
        this.fileUploadSetting = JSON.parseObject(ObjectUtils.defaultIfNull(entity.getFileUploadSetting(), JSON_OBJECT_EMPTY));
        this.ttsAutoplay = entity.getTtsAutoplay();
        this.sttAutosend = entity.getSttAutosend();
        this.createTime = entity.getCreateTime();
        this.updateTime = entity.getUpdateTime();
    }

}
